#include <iostream>

using namespace std;

class Solution 
{
public:
    void sortColors(int A[], int n) 
	{
        // Start typing your C/C++ solution below
        // DO NOT write int main() function
		int n0 = 0, n1 = 0, n2 = 0;
		for(int i=0;i<n;i++)
		{
			if(A[i] == 0)
			{
				n0++;
				A[n0-1] = 0;
				if(n1!=0)
					A[n0+n1-1] = 1;
				if(n2 != 0)
					A[n0+n1+n2-1] = 2;
			}
			else if(A[i] == 1)
			{
				n1++;
				A[n0+n1-1] = 1;
				if(n2!=0)
					A[n0+n1+n2-1] = 2;
			}
			else
			{
				n2++;
			}
		}
    }
};

int main()
{
	Solution s;
	int n;
	while(cin>>n)
	{
		if(n<=0)
			break;
		int* A = new int[n];
		for(int i=0;i<n;i++)
			cin>>A[i];
		s.sortColors(A,n);
		for(int i=0;i<n;i++)
			cout<<A[i]<<" ";
		cout<<endl;
	}
}
